
getAllTeacher();
			$(".startSearch").click(function() {

				getAllTeacher();
			})
			//			获取所有用户开始
			function getAllTeacher() {
				var name = $("#teachername").val();
				var rank = $('#teacherrank').val();
				layui.use('table', function() {
					var table = layui.table;
					//return;

					//渲染
					var stamp = new Date().getTime();
					var systoken=sessionStorage.getItem('systoken');
					var param = {
						id: '',
						name: name,
						//					gender: "",
						rank: rank,
						stamp: stamp,
						systoken:systoken,
						version: 0,
						visitPlat: 0,
						visitType: 0,
						isUsed: 0,
					};
					param = JSON.stringify(param);
					var url = path+"/course/queryCourse";
					var defaultpageSise = 10;
					window.ins1 = _render(defaultpageSise);
					function _render(pageSize) {
					table.render({
						elem: '#test',
						height: 600,
						title: '用户数据表',
						method: 'post',
						//					url: 'json/table/demo1.json'
						url: url,

							//,size: 'lg'
						//						page: {
						//
						//						},
						page: true,
						where: {
							param: param
						},
						autoSort: false,
						loading: false,
						parseData: function(res) {
							return {
								"code": res.status,
								"msg": res.info,
								"count": res.total,
								"data": res.items
							};
						},
						done: function(res) {
							$('#inp').val(pageSize);
							$("#inp").on('blur', function() {
						      var inputVal = $("#inp").val();
						      _render(inputVal);
				 });
						},
						totalRow: true,
						limit: 30,
						toolbar: '#toolbarDemo',
						cols: [
							[{
									type: 'checkbox',
									fixed: 'left'
								},
								//							{
								//								field: 'id',
								//								title: 'ID',
								//								width: 80,
								//								fixed: 'left',
								//								unresize: true,
								//								sort: true,
								//								totalRowText: '合计：'
								//							},

								{
									//								field: 'sex',
									field: 'name',
									title: '课程名称',
									width: 150,
									//								edit: 'text',
									//								sort: true
								},
								{
									field: 'time',
									title: '课程时长',
									width: 100,
									edit: 'text',
									//								sort: true
								},
								{
									//								field: 'sex',
									field: 'createTime',
									title: '创建时间',
									width: 150,
									//								edit: 'text',
									//								sort: true
								},
								{
									field: 'updateTime',
									title: '更新时间',
									width: 100
								},
								{
									field: 'note',
									title: '课程描述',
									edit: 'text',
									width: 200
								},								
								{
									fixed: 'right',
									title: '操作',
									toolbar: '#barDemo',
									width: 180
								}
							]
						],
						page: true
							,
						limits: [3, 5, 10],
						limit: pageSize
							,
						loading: true //请求数据时，是否显示loading

					});
				};
					//工具栏事件
					table.on('toolbar(test)', function(obj) {
						var checkStatus = table.checkStatus(obj.config.id);
						switch(obj.event) {
							case 'add':
								layer.msg('添加');
								break;
							case 'update':
								layer.msg('编辑');
								break;
							case 'delete':
								layer.msg('删除');
								break;
							case 'getCheckData':
								var data = checkStatus.data;
								break;
							case 'getCheckLength':
								var data = checkStatus.data;
								layer.msg('选中了：' + data.length + ' 个');
								break;
							case 'isAll':
								layer.msg(checkStatus.isAll ? '全选' : '未全选')
								break;
						};
					});

					//监听表格行点击
					table.on('tr', function(obj) {
					});

					//监听表格复选框选择
					table.on('checkbox(test)', function(obj) {
					});

					//监听表格单选框选择
					table.on('radio(test)', function(obj) {
					});
					//监听表格单选框选择
					table.on('rowDouble(test)', function(obj) {
					});

					//监听单元格编辑
					table.on('edit(test)', function(obj) {

						var value = obj.value //得到修改后的值
							,
							xgdata = obj.data //得到所在行所有键值
							,
							id = xgdata.id //得到id
							,
							field = obj.field; //得到字段

						//编辑单元格
						editTeacher();
						$('.teachername').val("");
						//修改成功与后台交互
						function editTeacher() {

							var stamp = new Date().getTime();
							var version = 0;
							var visit_plat = 0;
							var visit_type = 0;
							var is_used = 0;
							var systoken=sessionStorage.getItem('systoken');
							var param1 = {
								//										obj[field]:value,
								id: id,
								stamp: stamp,
								systoken:systoken,
								version: version,
								visit_plat: visit_plat,
								visit_type: visit_type,
								is_used: is_used
							}
							var param=Object.assign(xgdata,param1);
							param = JSON.stringify(param);
							$.ajax({
								url: "http://192.168.1.107:8083/teacher/updateTeacher",
								type: "post",
								data: {
									param: param
								},
								dataType: "json",
								success: function() {
									getAllTeacher();
								}
							})
						}
					});

					//监听行工具事件
					table.on('tool(test)', function(obj) {
						var data = obj.data;
						//						var id = data.id;
						if(obj.event === 'del') {
							layer.confirm('确定删除这一行数据?', function(index) {
								//							这里编写删除的逻辑,下面两个步骤是完成与后台的交互后才执行的
								var id = data.id;
								obj.del();
								layer.close(index);
								//								删除表格
								deleteTeacher();

								function deleteTeacher() {
									var systoken=sessionStorage.getItem('systoken');
									var stamp = new Date().getTime();
									var version = 0;
									var visit_plat = 0;
									var visit_type = 0;
									var is_used = 0;
									var param = {
										id: id,
										systoken:systoken,
										stamp: stamp,
										version: version,
										visit_plat: visit_plat,
										visit_type: visit_type,
										is_used: is_used
									}
									param = JSON.stringify(param);
									var url =path+"/teacher/deleteTeacher";
									$.ajax({
										url:url,
										type: "post",
										data: {
											param: param
										},
										dataType: "json",
										success: function() {
											getAllTeacher();
										}
									})
								}
							});
						} else if(obj.event === 'edit') {
							layer.prompt({
								formType: 2,
								value: data.liaison
								//							value: data.experience
							}, function(value, index) {
								obj.update({
									email: value
								});
								layer.close(index);
							});
						}
					});

					//监听排序
					table.on('sort(test)', function(obj) {
						layer.msg('已经完成排序！ ' + obj.field + ' ' + obj.type);
						//服务端排序
						table.reload('test', {
							initSort: obj
								//,page: {curr: 1}
								,
							where: {
								key: obj.field
									,
								order: obj.type
							}
						});
					});

					var $ = layui.jquery,
						active = {
							parseTable: function() {
								table.init('parse-table-demo', {
									limit: 3
								});
							},
							add: function() {
								table.addRow('test')
							}
						};
					$('i').on('click', function() {
						var type = $(this).data('type');
						active[type] ? active[type].call(this) : '';
					});
					$('.layui-btn').on('click', function() {
						var type = $(this).data('type');
						active[type] ? active[type].call(this) : '';
					})

				});

			}